package com.vinhvt.effiport.algorithm.genetic.bio;

import com.vinhvt.effiport.financial.ep.mapper.EffiPortGeneMap;

public abstract class Gene {	
	
	protected boolean[] bits = null;	
	private Number value = null;	
	private EffiPortGeneMap genMap = null;	
	
	public Gene(boolean bits[]) {
		setBits(bits);				
	}	

	public Gene(Number num){
		setValue(num);	
	}
	
	/**
	 * Cipher the Position into an array of boolean.
	 * 
	 * @return the boolean[]
	 */
	public abstract boolean[] cipher();
	
	/**
	 * Decipher an array of boolean into the Position of an Asset in Asset Gene Map
	 * 
	 * @return the number
	 */
	public abstract Number decipher();
	
	
	public void setBits(boolean bits[]) {
		this.bits = bits;
	}

	public boolean[] getBits() {
		return bits;
	}
	
	public void setGenMap(EffiPortGeneMap genMap) {
		this.genMap = genMap;
	}

	public EffiPortGeneMap getGenMap() {
		return genMap;
	}

	public void setValue(Number value) {
		this.value = value;
	}

	public Number getValue() {
		return this.value;
	}	
	
	@Override
	public String toString() {
		String result = "";
		
		for(int i = 0; i < bits.length; i++) {
			result += bits[i] ? "1" : "0";
		}
		
		return result;
	}
}
